import request from '@/utils/request'
// import qs from 'qs'

// RADVD

// 修改信息
export function editRadvdInfo (params) {
  var data = fromData(params)
  return request({
    url: 'radvd/editInfo',
    method: 'post',
    data
  })
}

// 删除信息
export function delRadvdInfo (params) {
  var data = fromData(params)
  return request({
    url: 'radvd/del_info',
    method: 'post',
    data
  })
}

// 增加信息
export function addRadvdInfo (params) {
  var data = fromData(params)
  return request({
    url: 'radvd/addInfo',
    method: 'post',
    data
  })
}

// 开关
export function switchRadvd (params) {
  var data = fromData(params)
  return request({
    url: 'radvd/switch',
    method: 'post',
    data
  })
}

// 获取RADVD列表
export function getRadvdArray (params) {
  var data = fromData(params)
  return request({
    url: 'radvd/getRadvdArray',
    method: 'post',
    data
  })
}

// 获取RADVD状态
export function getRadvdStatus (params) {
  var data = fromData(params)
  return request({
    url: 'radvd/getRadvdStatus',
    method: 'post',
    data
  })
}

// 获取配置信息
export function getRadvdConfig (params) {
  var data = fromData(params)
  return request({
    url: 'radvd/getConfig',
    method: 'post',
    data
  })
}

// 编辑配置信息
export function editRadvdConfig (params) {
  var data = fromData(params)
  return request({
    url: 'radvd/editConfig',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }
